<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"  %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<HTML>
<HEAD>
 <style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family:  Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>
<script language="JavaScript" src="dialog.js"></script>

<Script language=JavaScript>
var sAction = "INSERT";
var sTitle = "<bean:message bundle='webEditor'  key='webEditor.Insert' />";

var oControl;
var oChild;
var oSeletion;
var sRangeType;

var sAlignFieldset = "";
var sAlignLegend = "";
var sBorderColor = "";
var sBgColor = "";

oSelection = dialogArguments.eWebEditor.document.selection.createRange();
sRangeType = dialogArguments.eWebEditor.document.selection.type;

if (sRangeType == "Control") {
	if (oSelection.item(0).tagName == "FIELDSET"){
		sAction = "MODI";
		sTitle = "<bean:message bundle='webEditor'  key='webEditor.Modify' />";
		oControl = oSelection.item(0);
		sAlignFieldset = oControl.align;
		oChild = GetChildElement(oControl,"LEGEND");
		if (oChild) sAlignLegend = oChild.align;
		sBorderColor = oControl.style.borderColor;
		sBgColor = oControl.style.backgroundColor;
	}
}


document.write("<title><bean:message bundle='webEditor'  key='webEditor.InsertFieldset.Title' />(" + sTitle + ")</title>");


function InitDocument(){
	SearchSelectValue(d_alignfieldset, sAlignFieldset.toLowerCase());
	SearchSelectValue(d_alignlegend, sAlignLegend.toLowerCase());

	d_bordercolor.value = sBorderColor;
	s_bordercolor.style.backgroundColor = sBorderColor;
	d_bgcolor.value = sBgColor;
	s_bgcolor.style.backgroundColor = sBgColor;

}


function GetChildElement(obj, sTag){
	var el;
	for (var i=0;i<obj.children.length;i++){
		if (obj.children[i].tagName==sTag){
			return obj.children[i];
		}else{
			el=GetChildElement(obj.children[i], sTag);
			if (el){
				return el;
			}
		}
	}
	return null;
}

</script>

<SCRIPT event=onclick for=Ok language=JavaScript>

	sBorderColor = d_bordercolor.value;
	if (!IsColor(sBorderColor)){
		BaseAlert(d_bordercolor,'<bean:message bundle="webEditor"  key="webEditor.borderColor.alert" />');
		return;
	}

	sBgColor = d_bgcolor.value;
	if (!IsColor(sBgColor)){
		BaseAlert(d_bgcolor,'<bean:message bundle="webEditor"  key="webEditor.bgColor.alert" />');
		return;
	}

	sAlignFieldset = d_alignfieldset.options[d_alignfieldset.selectedIndex].value;
	sAlignLegend = d_alignlegend.options[d_alignlegend.selectedIndex].value;

	if (sAction == "MODI") {
		oControl.align = sAlignFieldset;
		if (oChild) oChild.align = sAlignLegend;
		oControl.style.borderColor = sBorderColor;
		oControl.style.backgroundColor = sBgColor;
	}else{
		dialogArguments.insertHTML("<fieldset align='"+sAlignFieldset+"' style='border-color:"+sBorderColor+";background-color:"+sBgColor+"'><legend align="+sAlignLegend+"><bean:message bundle='webEditor'  key='webEditor.title' /></legend><bean:message bundle='webEditor'  key='webEditor.content' /></fieldset>");
	}

	window.returnValue = null;
	window.close();
</SCRIPT>
</HEAD>

<body bgcolor="menu" onload="InitDocument()">

<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
	<td>
	<fieldset>
	<legend><bean:message bundle='webEditor'  key='webEditor.HorAlign' /></legend>
	<table border=0 cellpadding=0 cellspacing=0>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key='webEditor.InsertFieldset.ChannelAlign' /></td>
		<td width=5></td>
		<td><select id=d_alignfieldset style="width:72px"><option value=''><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.1' /></option><option value='left'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.2' /></option><option value='center'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.5' /></option><option value='right'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.3' /></option></select></td>
		<td width=40></td>
		<td><bean:message bundle='webEditor'  key='webEditor.InsertFieldset.TitleAlign' /></td>
		<td width=5></td>
		<td><select id=d_alignlegend style="width:72px"><option value=''><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.1' /></option><option value='left'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.2' /></option><option value='center'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.5' /></option><option value='right'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.3' /></option></select></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	</table>
	</fieldset>
	</td>
</tr>
<tr><td height=5></td></tr>
<tr>
	<td>
	<fieldset>
	<legend><bean:message bundle='webEditor'  key='webEditor.InsertFieldset.ColorPop' /></legend>
	<table border=0 cellpadding=0 cellspacing=0>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key='webEditor.RimColor' /></td>
		<td width=5></td>
		<td><input type=text id=d_bordercolor size=7 value=""></td>
		<td><img border=0 src="../sysimage/rect.gif" width=18 style="cursor:hand" id=s_bordercolor onclick="SelectColor('bordercolor')"></td>
		<td width=40></td>
		<td><bean:message bundle='webEditor'  key='webEditor.Bgcolor' /></td>
		<td width=5></td>
		<td><input type=text id=d_bgcolor size=7 value=""></td>
		<td><img border=0 src="../sysimage/rect.gif" width=18 style="cursor:hand" id=s_bgcolor onclick="SelectColor('bgcolor')"></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	</table>
	</fieldset>
	</td>
</tr>
<tr><td height=5></td></tr>
<tr><td align=right><input type=submit value="<bean:message bundle='webEditor'  key='webEditor.Confirm' />" id=Ok>&nbsp;&nbsp;<input type=button value="<bean:message bundle='webEditor'  key='webEditor.Cancel' />" onclick="window.close();"></td></tr>
</table>

</body>
</html>